var router = require('libs/router').router;
var pages = require('libs/pages');
var ItemMixin = require('mixins/item');
var libs = require('libs/libs');
var api = libs.api;
var evaData = {};
var expevalLogin = SA.get('USER');

var bindEvent = function(){
    //此处各种dom 操作
    $(".starBox1 i").click(function (){
        var l=$(this).index();
        $(".starBox1 i").removeClass("starCheck");
        for(var i=0;i<=l;i++){
            $(".starBox1 i").eq(i).addClass("starCheck");
        }
    })
    $(".evaluateBtn").click(function (){
        var eData = {
            login:expevalLogin.login,
            orderId:evaData.orderId,
            score:$(".starCheck").size()
        }
        api.req('/evaluateSubmit', eData ,function (data){
            console.log(data);
        })
    })
    libs.inject()
        .js(['/js/t/jq/ui.js', 'uiLib'], evaluate)
    function evaluate(){

    }

};

var Evaluate = React.createClass({
    mixins: [ItemMixin],
    render:function(){
        return (
            <div className="evaluateWarp">
                <p>感谢您使用大白管家服务<br/>请对本次服务进行评价</p>
                <div className="starBox1">
                    <i></i>
                    <i></i>
                    <i></i>
                    <i></i>
                    <i></i>
                </div>
                <div className="evaluateBtn f_submit u-mt-15">
                    <input type="button" value="提交" className="f_btn" />
                </div>
            </div>
        )
    }
});

function start(name){
    return pages.new({
        boot: function(){
        },
        trigger:function(self, data){
            this.libs.changeTitle('我要收件');    //更改当前页面标题
            if(data  && data.orderId){
                self.main(self, data);
                evaData = data;
            }
        },
        main: function(self, data){
            this.render(
                <Evaluate itemDefaultMethod={bindEvent} data={data} />,
                document.getElementById(name)
            )
        }
    })
}

module.exports = start;
